<template>
    <div>
        <h1 class="stuinfo_personal_title">某个学生入学成绩查询</h1>
        <el-row>
            <el-col :span="6" :offset="8">
                <el-input v-model="stu_id"></el-input>
            </el-col>
            <el-col :span="4" :offset="1">
                <el-button @click="getStuInfo">搜索</el-button>
            </el-col>
        </el-row>
        <div class="result_wrap" v-if="show">
            <div class="table_wrap">
            <el-table :data="result" style="width: 100%">
            <el-table-column prop="stu_id" label="学号" width="180">
            </el-table-column>
            <el-table-column prop="stu_name" label="姓名" width="180">
            </el-table-column>
            <el-table-column prop="chinese" label="语文" width="180">
            </el-table-column>
            <el-table-column prop="english" label="英语" width="180">
            </el-table-column>
            <el-table-column prop="math" label="数学" width="180">
            </el-table-column>
            <el-table-column prop="lizong" label="理综" width="180">
            </el-table-column>
            <el-table-column prop="wenzong" label="文综" width="180">
            </el-table-column>
            </el-table>
            </div>
    </div>
    </div>
</template>

<script>
import {req_search_entry} from '@/api/examInfo.js';
    export default {
        data(){
            return{
                stu_id:'',
                result:[],
                show:false,
            }
        },
        methods:{
            async getStuInfo(){
                console.log(this.stu_id);
                let result =await req_search_entry(this.stu_id);
                console.log(result);
                this.result=result.data;
                this.show=true;
                console.log(this.result);
                // 服务器有该数据
                // 服务器当中要是没有该条数据
                if (result.data.length > 0) {
                this.result = result.data;
                this.show = true;
                console.log(this.result);
            } else {
                this.$message({
                message: "该学号不存在，请重新输入",
                type: "error",
                });
            }
        }
    }
}
</script>

<style lang="scss" scoped>
div{
    .stuinfo_personal_title{
        height: 30px;
        text-align: center;
        font-size: 25px;
        font-weight: 700;
        margin-bottom: 20px;
    }
    .result_wrap {
        text-align: center;
        .table_wrap {
        margin-top: 30px;
        height: 300px;
        }
  }
}
</style>